package com.EAIPClub.CodeLab.CodeIde.controller;

import com.EAIPClub.CodeLab.CodeIde.service.CodeIdeService;
import com.api.POJO.CodeLab.CodeIde.CodeIdeInfo;
import com.api.POJO.CodeLab.CodeIde.CodeIdeReturnMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :CodeIde控制层
 * @Author :崔昌赫
 * @Date : 2021/10/27
 */
@RestController
@CrossOrigin(origins = "*",maxAge = 3600)
public class CodeIdeController {

    private CodeIdeService codeIdeService;

    @Autowired
    public void setCodeIdeService(CodeIdeService codeIdeService) {
        this.codeIdeService = codeIdeService;
    }

    @GetMapping("/codelab/codeide/users/token/{token}")
    CodeIdeReturnMsg loginCodeIde(@PathVariable String token){
        return codeIdeService.loginCodeIde(token);
    }

    @GetMapping("/codelab/codeide/users/add/token")
    CodeIdeReturnMsg registerCodeIde(@RequestParam String token,@RequestParam String password){
        CodeIdeInfo info = new CodeIdeInfo(token,password);
        return codeIdeService.registerCodeIde(info);
    }

    @GetMapping("/codeide/users/login")
    CodeIdeReturnMsg loginCodeIdeByToken(@RequestParam String ticket,@RequestParam String token){
        return codeIdeService.loginCodeIdeByToken(ticket,token);
    }


}
